package com.haipumi.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.haipumi.beans.haipumi_task;
import com.haipumi.biz.IBackTaskBiz;
import com.haipumi.mapper.BackTaskMapper;

@Service("backTaskBiz")
public class BackTaskBizImpl implements IBackTaskBiz {

	@Autowired
	BackTaskMapper backTaskMapper;
	
	@Override
	public List<haipumi_task> findAllTask(int start,int end,String sort,String order) {
		List<haipumi_task> tasklist=null;
		Map<String ,Object>map=new HashMap<String,Object>();
		map.put("start", start);
		map.put("end", end);
		map.put("sort", sort);
		map.put("order", order);
		tasklist=backTaskMapper.findAllTask(map);
		return tasklist;
	}

	@Override
	public int countAllTask(int start,int end,String sort,String order) {
		int r=0;
		Map<String ,Object>map=new HashMap<String,Object>();
		map.put("start", start);
		map.put("end", end);
		map.put("sort", sort);
		map.put("order", order);
		r=backTaskMapper.countAllTask(map);
		return r;
	}

	@Override
	public boolean checkTask(String tid) {
		if(backTaskMapper.checkTask(tid)>0){
			return true;
		}
		return false;
	}

	@Override
	public boolean caozuo(String tid, String type) {
		boolean flag=false;
		if("frazetask".equals(type)){
			flag=(backTaskMapper.frazetask(tid)>0)?true:false;
		}else if("timeout".equals(type)){
			flag=(backTaskMapper.timeouttask(tid)>0)?true:false;
		}
		return flag;
	}

	@Override
	public boolean finishTask(String tid) {
		if(backTaskMapper.finishTask(tid)>0){
			return true;
		}
		return false;
	}


}
